/**
 * Created by Administrator on 18-6-6.
 */
/**
 * Created by waterworld on 17-11-23.
 */
var config=require('./config/config');
var P = require("bluebird");
var userDao = require('./dao/userDao');
var predis=require('./dao/predis');
var Token=require('./token');
var phttp=require('./util/phttp');
var iconst=require('./iconst');
var http = require('http');
var cnst=require('./const');
var fileUtil = require('./util/fileUtil');
var wxsign=require('./util/wxsign');
var io=require('socket.io/node_modules/socket.io-client');

var redis=new predis({port:6379,host:'101.37.164.134'});
var express = require('express');

//var  app=require('./webapp');
//app.redis=redis;
//app.userDao=userDao;
//app.mysql=mysql;
console.logList=[];
var  initAsync= P.coroutine(function*()
{
    redis.selectDb(1);
    var  uid=121495;
   var userInfo=yield userDao.getUserByIdAsync(uid);
    var  name="戒酒的李白";
    yield userDao.setUserName(uid,name);
    var  account=userInfo.account;
    var info=yield redis.getHashItem('weixinCache',account);
    if(info)
    {   info=JSON.parse(info)
        info.name=name;
        var s=JSON.stringify(info);
        console.log('after rename ',s)
        yield redis.setHashItem('weixinCache',account,s);
    }

    var info=yield redis.getHashItem('weixinCache',uid);
    if(info)
    {   info=JSON.parse(info)
        info.name=name;
        var s=JSON.stringify(info);
        console.log('after rename ',s)
        yield redis.setHashItem('weixinCache',uid,s);
    }

    console.log('总数',n);

});

initAsync().catch(function(e)
{   console.logw('err', e.message);
});

function noop(e){
    console.logw('process exception', e.message);
}

process.on('uncaughtException', noop)
